-
Notifications
You must be signed in to change notification settings - Fork 103
Add withKnownIssue comments to known Issues #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci test |
### Motivation: The Comment passed to withKnownIssue() is currently only used when a known issue does not occur. When a known issue does occur, it is marked isKnown but does not contain any record of the withKnownIssue() comment, making it harder to understand why the issue was considered to be known, especially if there are multiple nested withKnownIssue() calls. ### Modifications: When an issue is marked "known" by a `withKnownIssue()` call, the recorded issue will now have multiple comments in its `comments` array: 1. The comment passed to `withKnownIssue()`, if any 2. The Issue's own comment(s) If the issue is recorded within multiple nested `withKnownIssue()` calls, only the comment of the innermost matching call is added to the Issue. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
cf99d11
to
c6cbd3d
Compare
@swift-ci test |
@stmontgomery I took a crack at putting the known-issue data into a separate stored property and converting
|
@swift-ci test |
@swift-ci test |
@swift-ci test |
After discussion with @grynspan and @stmontgomery I've reverted the ABI changes. Instead, we append the known issue comment (if any) to |
@swift-ci please test |
I wanted to see if the known issue comment now appears in struct TryIt {
@Test func knownIssueTest() async throws {
withKnownIssue("known issue comment") {
Issue.record("issue comment")
}
}
@Test func knownIssueTest_throws() async throws {
withKnownIssue("known issue comment") {
struct TheError: Error {}
throw TheError()
}
}
} Here's what I got: $ SWT_SF_SYMBOLS_ENABLED=no xcrun swift test --filter TryIt
Building for debugging...
[1/1] Write swift-version--1EBDF3DDE0C0C582.txt
Build complete! (0.16s)
Test Suite 'Selected tests' started at 2025-04-07 10:48:10.677.
Test Suite 'swift-testingPackageTests.xctest' started at 2025-04-07 10:48:10.678.
Test Suite 'swift-testingPackageTests.xctest' passed at 2025-04-07 10:48:10.678.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'Selected tests' passed at 2025-04-07 10:48:10.678.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
◇ Test run started.
↳ Testing Library Version: feb96cf762e5732f8702e1dc9755fa2908bfb5ba (modified)
◇ Suite TryIt started.
◇ Test knownIssueTest_throws() started.
◇ Test knownIssueTest() started.
✘ Test knownIssueTest() recorded a known issue at EventRecorderTests.swift:660:19: Issue recorded
↳ issue comment
↳ known issue comment
✘ Test knownIssueTest() passed after 0.001 seconds with 1 known issue.
✘ Test knownIssueTest_throws() recorded a known issue at EventRecorderTests.swift:665:19: Caught error: TheError()
↳ known issue comment
↳ known issue comment
✘ Test knownIssueTest_throws() passed after 0.001 seconds with 1 known issue.
✘ Suite TryIt passed after 0.001 seconds with 2 known issues.
✘ Test run with 2 tests passed after 0.001 seconds with 2 known issues. This looks decent, but you can see that Here are some ways to handle this:
I'm leaning toward 4 (and would add a test for it of course). |
I implemented this. |
@swift-ci please test |
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Jonathan Grynspan <[email protected]>
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicky formatting comments I saw as I caught up with the latest changes
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Sources/Testing/Events/Recorder/Event.HumanReadableOutputRecorder.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Stuart Montgomery <[email protected]>
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few more suggestions and style cleanups, but I think the behavior and logic all make sense now!
Co-authored-by: Stuart Montgomery <[email protected]>
@swift-ci please test |
The macOS and Linux CI failures are expected to be resolved by swiftlang/swift#80830, but the release of a new |
Add withKnownIssue comments to known Issues
Motivation:
The Comment passed to withKnownIssue() is currently only used when a known issue does not occur. When a known issue does occur, it is marked isKnown but does not contain any record of the withKnownIssue() comment, making it harder to understand why the issue was considered to be known, especially if there are multiple nested withKnownIssue() calls.
Modifications:
When an issue is marked "known" by a
withKnownIssue()
call, the recorded issue will now have a newknownIssueContext
property containing the comment passed towithKnownIssue()
(if any). This comment will be included in themessages
array of theABI.EncodedEvent
that represents the issue.If the issue is recorded within multiple nested
withKnownIssue()
calls,knownIssueContext
corresponds to the innermost matching call.The
Issue.isKnown
setter is now deprecated and a no-op.When an error is thrown within a
withKnownIssue()
call, theIssue
passed to the issue matcher used to have the known issue comment inIssue.comments
. That has now been removed; Issues for thrown errors now have no comments at all when passed to the issue matcher. This matches Issues for thrown errors that occur outside ofwithKnownIssue()
calls.Checklist: